<template>
	<view>
		<u-modal :show="show" cancelColor="#555" confirmColor="#3478f5" :showCancelButton="true" :title="title"
			@cancel="cancel" @confirm="confirm"></u-modal>
		<!-- 头部 -->
		<view class="toubox" v-if="!is_login" @click="login()">
			<view class="flexbetween">
				<view class="flexleft">
					<view class="touxiang margin_right3">
						<image src="@/static/image/sysem/weidenglu.png" mode=""></image>
					</view>
					<view class="titletext xiaobai fonweight">未登录，点击登录</view>
				</view>
				<u-icon name="arrow-right" color="#fff" size="30"></u-icon>
			</view>
		</view>
		<view class="toubox" v-else @click="jumper('/pages/mypage/gerenxinxi')">
			<view class="flexbetween">
				<view class="flexleft">
					<view class="touxiang margin_right3">
						<image :src="userInfo.avatar_text" mode=""></image>
					</view>
					<view class="">
						<view class="titletext xiaobai fonweight">{{userInfo.nickname}}</view>
						<view class="flexleft" @click.stop="copy(userInfo.invite_code)">
							<view class="ershil xiaobai nofonweight margin_top1 margin_right2">
								邀请码：{{userInfo.invite_code}}</view>
							<image src="../../static/image/sysem/copy.png" mode="" style="width: 30rpx;height: 30rpx;">
							</image>
						</view>
					</view>
				</view>
				<u-icon name="arrow-right" color="#fff" size="30"></u-icon>
			</view>
		</view>
		<!--  -->
		<view class="mainpadding" style="position: relative; top: -100rpx;">
			<view class="block ffffff radius flexbetween" v-if="is_login">
				<view class="wushi flexcenter" @click="tzgywm(1)">
					<view class="flexleft">
						<view class="flicon margin_right3">
							<image src="../../static/image/sysem/jf.png" mode=""></image>
						</view>
						<view class="">
							<view class="ershiba nofonweight xiaohei">{{userInfo.score || 0}}</view>
							<view class="ershiba nofonweight xiaohei margin_top1">我的积分</view>
						</view>
					</view>
				</view>
				<view class="wushi flexcenter" @click="tzgywm(2)">
					<view class="flexleft">
						<view class="flicon margin_right3">
							<image src="../../static/image/sysem/yj.png" mode=""></image>
						</view>
						<view class="">
							<view class="ershiba nofonweight xiaohei">{{userInfo.money || "0.00"}}</view>
							<view class="ershiba nofonweight xiaohei margin_top1">我的佣金</view>
						</view>
					</view>
				</view>
			</view>
			<!-- 我的服务 -->
			<view class="mainpadding ffffff margin_top radius">
				<view class="xiaohei fonweight titletext">我的服务</view>
				<view class="flexleft flex_wrap ">
					<view class="ershiw flexcenter margin_top" @click="jumper('/pages/mypage/shoukuansz')">
						<view class="">
							<view class="fuicon">
								<image src="../../static/image/sysem/ysk.png" mode=""></image>
							</view>
							<view class="xiaohei nofonweight ershiba margin_top1">收款设置</view>
						</view>
					</view>
					<view class="ershiw flexcenter margin_top" @click="jumper('/pages/mypage/shouhuodizhi')">
						<view class="">
							<view class="fuicon">
								<image src="../../static/image/sysem/shdz.png" mode=""></image>
							</view>
							<view class="xiaohei nofonweight ershiba margin_top1">收货地址</view>
						</view>
					</view>

					<view class="ershiw flexcenter margin_top" @click="jumper('/pages/system/system?type=6')">
						<view class="">
							<view class="fuicon">
								<image src="../../static/image/sysem/fxts.png" mode=""></image>
							</view>
							<view class="xiaohei nofonweight ershiba margin_top1">风险提示</view>
						</view>
					</view>

					<view class="ershiw flexcenter margin_top" @click="jumper('/pages/mypage/xitonggg')">
						<view class="">
							<view class="fuicon">
								<image src="../../static/image/sysem/xtgg.png" mode=""></image>
							</view>
							<view class="xiaohei nofonweight ershiba margin_top1">系统公告</view>
						</view>
					</view>
					<view class="ershiw flexcenter margin_top" @click="jumper('/pages/mypage/kefu')">
						<view class="">
							<view class="fuicon">
								<image src="../../static/image/sysem/kf.png" mode=""></image>
							</view>
							<view class="xiaohei nofonweight ershiba margin_top1">客服电话</view>
						</view>
					</view>

					<view class="ershiw flexcenter margin_top" @click="jumper('/pages/system/system?type=3')">
						<view class="">
							<view class="fuicon">
								<image src="../../static/image/sysem/gywm.png" mode=""></image>
							</view>
							<view class="xiaohei nofonweight ershiba margin_top1">关于我们</view>
						</view>
					</view>
					<view class="ershiw flexcenter margin_top" @click="jumper('/pages/mypage/wodehaoyou')">
						<view class="">
							<view class="fuicon">
								<image src="../../static/image/sysem/hy.png" mode=""></image>
							</view>
							<view class="xiaohei nofonweight ershiba margin_top1">我的好友</view>
						</view>
					</view>
					<view class="ershiw flexcenter margin_top" @click="jumper('/pages/mypage/wodeshuju')">
						<view class="">
							<view class="fuicon">
								<image src="../../static/image/sysem/sj.png" mode=""></image>
							</view>
							<view class="xiaohei nofonweight ershiba margin_top1">我的数据</view>
						</view>
					</view>
					<view class="ershiw flexcenter margin_top" @click="tzgywm(3)">
						<view class="">
							<view class="fuicon">
								<image src="../../static/image/sysem/tx.png" mode=""></image>
							</view>
							<view class="xiaohei nofonweight ershiba margin_top1">团队奖励</view>
						</view>
					</view>
					<view class="ershiw flexcenter margin_top" @click="jumper('/pages/mypage/tuiguang')">
						<view class="">
							<view class="fuicon">
								<image src="../../static/image/sysem/tg.png" mode=""></image>
							</view>
							<view class="xiaohei nofonweight ershiba margin_top1">推广</view>
						</view>
					</view>
					<view class="ershiw flexcenter margin_top" @click="smrz">
						<view class="">
							<view class="fuicon">
								<image src="../../static/image/sysem/smrz.png" mode=""></image>
							</view>
							<view class="xiaohei nofonweight ershiba margin_top1">实名认证</view>
						</view>
					</view>
					<view class="ershiw flexcenter margin_top" @click="jumper('/pages/system/system?type=4')">
						<view class="">
							<view class="fuicon">
								<image src="../../static/image/sysem/yhzn.png" mode=""></image>
							</view>
							<view class="xiaohei nofonweight ershiba margin_top1">用户指南</view>
						</view>
					</view>
					<view class="ershiw flexcenter margin_top" @click="jumper('/pages/system/system?type=5')">
						<view class="">
							<view class="fuicon">
								<image src="../../static/image/sysem/pmgz.png" mode=""></image>
							</view>
							<view class="xiaohei nofonweight ershiba margin_top1">拍卖规则</view>
						</view>
					</view>
					<view class="ershiw flexcenter margin_top" @click="show = true" v-if="is_login">
						<view class="">
							<view class="fuicon">
								<image src="../../static/image/sysem/tc.png" mode=""></image>
							</view>
							<view class="xiaohei nofonweight ershiba margin_top1">退出登录</view>
						</view>
					</view>
				</view>
				<!-- <view class="bigbtn margin_top"  @click="show = true">退出登录</view> -->
			</view>

		</view>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				show: false,
				title: '确定要退出当前账户么？',
				is_login: false,
				userInfo: {},
			}
		},
		onShow() {
			this.is_login = httpRequest.checkIsLogin();
			if (this.is_login) {
				this.init()
			}else{
				this.userInfo = {}
			}
		},
		methods: {

			init() {
				httpRequest.request('/api/user/index', 'GET', {}).then(res => {
					this.userInfo = res.data
				})
			},
			tzgywm(i) {
				uni.navigateTo({
					url: '/pages/mypage/wodejf?type=' + i
				})
			},
			// 退出登录
			cancel() {
				this.show = false
			},
			confirm() {
				this.show = false;
				// 将存储的数据改为空达到退出登录的效果
				uni.setStorageSync('token', "");
				uni.setStorageSync('userInfo', "");
				httpRequest.toast("退出登录成功")
				setTimeout(() => {
					this.is_login = false
				}, 1000)
			},
			smrz() {
				if (!this.userInfo.usersmrz) {
					uni.navigateTo({
						url: '/pages/mypage/shimingrenz'
					})
				} else {
					uni.navigateTo({
						url: "/pages/mypage/shenhe"
					})
				}

			},
			login() {
				uni.navigateTo({
					url: "/pages/login/login"
				})
			},
			copy(value) {
				uni.setClipboardData({
					data: value, //要被复制的内容
					success: () => {
						//复制成功的回调函数
						httpRequest.toast("复制成功")
					}
				});
			},
			jumper(url) {
				if (!httpRequest.checkIsLogin()) {
					uni.navigateTo({
						url: "/pages/login/login"
					})
					return false
				}
				uni.navigateTo({
					url: url
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.fuicon {
		margin: auto;
		width: 60rpx;
		height: 60rpx;

		image {
			width: 100%;
			height: 100%;
		}
	}

	.block {
		padding: 60rpx 30rpx;
	}

	.flicon {
		width: 80rpx;
		height: 80rpx;

		image {
			width: 100%;
			height: 100%;
		}
	}

	.touxiang {
		width: 110rpx;
		height: 110rpx;
		border-radius: 50%;

		image {
			border-radius: 50%;
			width: 100%;
			height: 100%;
		}
	}

	.toubox {
		padding: 40rpx 30rpx 110rpx;
		background-color: #3478f5;
	}
</style>